//
//  BCSearchStuffCollectionViewCell.m
//  BangcaiSale
//
//  Created by Liang Zhang on 16/7/18.
//  Copyright © 2016年 Bangcai. All rights reserved.
//

#import "BCSearchStuffCollectionViewCell.h"

@implementation BCSearchStuffCollectionViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    _typeButton.layer.cornerRadius = 3.f;
    
    //临时数据 ￥145/10斤
    NSString *price = @"145";
    
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:self.priceLable.text];
    UIColor *textColor = [UIColor colorWithRed:0.937 green:0.388 blue:0.310 alpha:1.000];
    [attributedString addAttribute:NSForegroundColorAttributeName  //文字颜色
                             value:textColor
                             range:NSMakeRange(0, @"￥".length+price.length)];
    [attributedString addAttribute:NSForegroundColorAttributeName  //文字颜色
                             value:[UIColor colorWithRed:0.702 green:0.702 blue:0.702 alpha:1.000]
                             range:NSMakeRange(@"￥".length+price.length, @"/".length+@"10".length+@"斤".length)];
    UIFont *priceFont = [UIFont systemFontOfSize:17.f];
    UIFont *weightFont = [UIFont systemFontOfSize:13.f];
    [attributedString addAttribute:NSFontAttributeName             //文字字体
                             value:priceFont
                             range:NSMakeRange(0, @"￥".length+price.length)];
    [attributedString addAttribute:NSFontAttributeName             //文字字体
                             value:weightFont
                             range:NSMakeRange(@"￥".length+price.length, @"/".length+@"10".length+@"斤".length)];
    self.priceLable.attributedText = attributedString;
}

+ (instancetype)cellWithCollectionView:(UICollectionView *)collectionView {
    static NSString *ID = @"SearchStuffCell";
    UINib *nib = [UINib nibWithNibName:@"BCSearchStuffCollectionViewCell" bundle: [NSBundle mainBundle]];
    [collectionView registerNib:nib forCellWithReuseIdentifier:ID];
    BCSearchStuffCollectionViewCell *cell = [[BCSearchStuffCollectionViewCell alloc] init];
    return cell;
}

- (IBAction)selectAction:(UIButton *)sender {
    _selectedBlock();
}

@end
